<%@Page Language="VB"%>
<%@Import Namespace="System.Drawing" %>
<html>
<head>

<script language="JScript">
<!--
function ShowHTMLContent() {
  var strURL = 'http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>?<% = Request.QueryString %>';
  var strDisplay = new String;
  var objHTTP = new ActiveXObject("microsoft.XMLHTTP")
  objHTTP.open('GET', strURL, false);
  objHTTP.send();
  var strReply = objHTTP.responseText;
  var intStart = strReply.indexOf('<!' + '--start-->') + 12;
  var intEnd = strReply.indexOf('<!' + '--end-->');
  if ((intStart > 0) && (intEnd > intStart))
    var strDisplay = strReply.substring(intStart, intEnd);
  document.all['outHTML'].innerText = strDisplay + ' ';
}
function SetCheck(strCheckboxName) {
  document.all[strCheckboxName].checked = true;
}
//-->
</script>

<!-- #include file="style.inc" -->
</head>
<body bgcolor="#ffffff" onload="ShowHTMLContent()">
<!--------------------------------------------------------------------------->
<span class="heading">ASP:Table Control</span><p />

<!--start-->
<asp:table id="MyControl" runat="server" />
<!--end-->

<p /><div id="outError" runat="server" /><p />
<font face="Courier New" size="2"><div style="background-color:gainsboro; padding-left:10px" id="outHTML">Fetching HTML content...</div></font>

<form runat="server" method="get">
<table border="0">
<tr>
<td align="right" nowrap="nowrap" colspan="2">Number of Rows =</td>
<td nowrap="nowrap"><select id="selRows" size="1" runat="server">
<option>1</option><option>2</option><option>3</option><option>4</option></select></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td align="right" nowrap="nowrap" colspan="2">Number of Columns =</td>
<td nowrap="nowrap"><select id="selCols" size="1" runat="server">
<option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBackColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BackColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBackColor" runat="server" onkeypress="SetCheck('chkBackColor')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBackImageUrl" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BackImageUrl =</td><td nowrap="nowrap"><select id="selBackImageUrl" size="1" runat="server" onchange="SetCheck('chkBackImageUrl')">
<option></option><option>Brick.gif</option><option>Marble.gif</option><option>Speckled.gif</option><option>Textured.gif</option><option>Weave.gif</option></select></td><td nowrap="nowrap"></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBorderColor" runat="server" onkeypress="SetCheck('chkBorderColor')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderStyle" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderStyle =</td><td nowrap="nowrap"><select id="selBorderStyle" size="1" runat="server" onchange="SetCheck('chkBorderStyle')">
<option value="4">BorderStyle.Solid</option><option value="3">BorderStyle.Dashed</option><option value="2">BorderStyle.Dotted</option><option value="5">BorderStyle.Double</option>
<option value="6">BorderStyle.Groove</option><option value="8">BorderStyle.Inset</option><option value="1">BorderStyle.None</option><option value="0">BorderStyle.NotSet</option>
<option value="9">BorderStyle.Outset</option><option value="7">BorderStyle.Ridge</option></select></td><td nowrap="nowrap"></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderWidth =</td><td nowrap="nowrap"><input type="text" size="2" id="txtBorderWidth" runat="server" onkeypress="SetCheck('chkBorderWidth')" />px</td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkCellPadding" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">CellPadding =</td><td nowrap="nowrap"><input type="text" size="3" id="txtCellPadding" runat="server" onkeypress="SetCheck('chkCellPadding')" />px</td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkCellSpacing" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">CellSpacing =</td><td nowrap="nowrap"><input type="text" size="3" id="txtCellSpacing" runat="server" onkeypress="SetCheck('chkCellSpacing')" />px</td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkForeColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">ForeColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtForeColor" runat="server" onkeypress="SetCheck('chkForeColor')" /></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkGridLines" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">GridLines =</td><td nowrap="nowrap"><select id="selGridLines" size="1" runat="server" onchange="SetCheck('chkGridLines')">
<option value="3">GridLines.Both</option><option value="1">GridLines.Horizontal</option><option value="0">GridLines.None</option><option value="2">GridLines.Vertical</option></select></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkHeight" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Height =</td><td nowrap="nowrap"><input type="text" size="3" id="txtHeight" runat="server" onkeypress="SetCheck('chkHeight')" />px</td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkHorizontalAlign" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">HorizontalAlign =</td><td nowrap="nowrap"><select id="selHorizontalAlign" size="1" runat="server" onchange="SetCheck('chkHorizontalAlign')">
<option value="2">HorizontalAlign.Center</option><option value="4">HorizontalAlign.Justify</option><option value="1">HorizontalAlign.Left</option><option value="0">HorizontalAlign.NotSet</option><option value="3">HorizontalAlign.Right</option></select></td><td></td>
<td nowrap="nowrap"></td><td align="right" nowrap="nowrap">ID =</td><td nowrap="nowrap"><% = MyControl.ID %></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkToolTip" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">ToolTip =</td><td nowrap="nowrap"><input type="text" size="20" id="txtToolTip" runat="server" onkeypress="SetCheck('chkToolTip')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selVisible" size="1" runat="server" onchange="SetCheck('chkVisible')"><option>True</option><option>False</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Width =</td><td nowrap="nowrap"><input type="text" size="3" id="txtWidth" runat="server" onkeypress="SetCheck('chkWidth')" />px</td><td></td>
<td nowrap="nowrap"><input type="button" Value="Reset" onclick="javascript:location.href='http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>'"></td><td nowrap="nowrap"></td><td nowrap="nowrap"><input type="submit" Value="Update" runat="server" /></td>
</tr>
</table>
</form>

<script language="VB" runat="server">
Sub Page_Load()

   outError.innerHTML = ""

   Try

     'create the table
      Dim intRows As Integer = selRows.Value
      Dim intCols As Integer = selCols.Value
      Dim intRowCount, intColCount As Integer
      Dim objRow As TableRow
      Dim objCell As TableCell
      For intRowCount = 0 To intRows - 1
        objRow = New TableRow()
        For intColCount = 0 To intCols - 1
          objCell = New TableCell()
          objCell.Controls.Add(New LiteralControl("R" & intRowCount & "C" & intColCount))
          objRow.Cells.Add(objCell)
        Next
        MyControl.Rows.Add(objRow)
      Next

      If IsPostBack() Then

         If chkBackColor.Checked Then MyControl.BackColor = Color.FromName(txtBackColor.Value)
         If chkBackImageUrl.Checked Then MyControl.BackImageUrl = selBackImageUrl.Value
         If chkBorderColor.Checked Then MyControl.BorderColor = Color.FromName(txtBorderColor.Value)
         If chkBorderStyle.Checked Then MyControl.BorderStyle = selBorderStyle.Value
         If chkBorderWidth.Checked Then MyControl.BorderWidth = Unit.Pixel(txtBorderWidth.Value)
         If chkCellPadding.Checked Then MyControl.CellPadding = txtCellPadding.Value
         If chkCellSpacing.Checked Then MyControl.CellSpacing = txtCellSpacing.Value
         If chkForeColor.Checked Then MyControl.ForeColor = Color.FromName(txtForeColor.Value)
         If chkGridLines.Checked Then MyControl.GridLines = selGridLines.Value
         If chkHeight.Checked Then MyControl.Height = Unit.Pixel(txtHeight.Value)
         If chkHorizontalAlign.Checked Then MyControl.HorizontalAlign = selHorizontalAlign.Value
         If chkToolTip.Checked Then MyControl.ToolTip = txtToolTip.Value
         If chkVisible.Checked Then MyControl.Visible = selVisible.Value
         If chkWidth.Checked Then MyControl.Width = Unit.Pixel(txtWidth.Value)

      End If

      txtBackColor.Value = MyControl.BackColor.Name
      selBackImageUrl.Value = MyControl.BackImageUrl
      txtBorderColor.Value = MyControl.BorderColor.Name
      selBorderStyle.Value = MyControl.BorderStyle
      txtBorderWidth.Value = MyControl.BorderWidth.Value
      txtCellPadding.Value = MyControl.CellPadding
      txtCellSpacing.Value = MyControl.CellSpacing
      txtForeColor.Value = MyControl.ForeColor.Name
      selGridLines.Value = MyControl.GridLines
      txtHeight.Value = MyControl.Height.Value
      selHorizontalAlign.Value = MyControl.HorizontalAlign
      txtToolTip.Value = MyControl.ToolTip
      selVisible.Value = MyControl.Visible
      txtWidth.Value = MyControl.Width.Value

   Catch objError As Exception

      outError.innerHTML = "<b>* Error</b>: " & objError.Message & "<p />"

   End Try

End Sub

</script>

<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>
